package string;

public class StringDemo {
    public static void main(String[] args) {
        String s1="abc";
        String s2 ="123abc";
        String s3 ="abc";
        System.out.println(s1==s2);
        System.out.println(s1==s3);

        String s4=new String("abc");
        System.out.println(s1==s4);//false

        s1 = s1+"!";//生成了一个新的new
        System.out.println(s1==s2);//false

        String s ="123";
        String s5=s+"abc";
        System.out.println(s5==s2);

        String s6 ="123"+"abc";//会预编译
        System.out.println(s6==s2);

        String s7 ="123"+"abc";
        String s8 =new String("123abc");
        System.out.println(s7.equals(s8));
    }
}
